<?php
/**
 * 微教育模块
 *
 * @author 高贵血迹
 */
        global $_W, $_GPC;
        $weid = $_W ['uniacid'];
        $from_user = $this->_fromuser;
		$schoolid = intval($_GPC['schoolid']);
		$openid = $_W['openid'];
		$obid = 1;
        //查询是否用户登录		
		
		$it = pdo_fetch("SELECT * FROM " . tablename($this->table_user) . " where id = :id ", array(':id' => $_SESSION['user']));	
		
		$school = pdo_fetch("SELECT * FROM " . tablename($this->table_index) . " where weid = :weid AND id=:id ORDER BY ssort DESC", array(':weid' => $weid, ':id' => $schoolid));
		
		$student = pdo_fetch("SELECT * FROM " . tablename($this->table_students) . " where weid = :weid AND id = :id", array(':weid' => $weid, ':id' => $it['sid']));		

		if ($_GPC['getalist']) {
			$pageSize = intval($_GPC['pageSize']);
			$nowPage = intval($_GPC['nowpage']);
			$item_per_page = empty($_GPC['pageSize']) ? 10 : intval($_GPC['pageSize']);
			$page_number = max(1, intval($_GPC['nowpage']));
			if(!is_numeric($page_number)){
	   			header('HTTP/1.1 500 Invalid page number!');  
	    		exit();  
			}
			$position = ($page_number-1) * $item_per_page;	
		    $leave1 = pdo_fetchall("SELECT id,bj_id,km_id,title,tname,createtime FROM " . tablename($this->table_notice) . " where weid = '{$weid}' And schoolid = '{$schoolid}' And bj_id = '{$student['bj_id']}' And type = 3  ORDER BY createtime DESC LIMIT " . $position . ',' . $item_per_page );
			
			foreach($leave1 as $key =>$row){
				$banji = pdo_fetch("SELECT sname FROM " . tablename($this->table_classify) . " where sid = :sid And schoolid = :schoolid ", array(':schoolid' => $schoolid,':sid' => $row['bj_id']));
				$leave1[$key]['banji'] = $banji['sname'];
				$leave1[$key]['name'] = $row['tname']."老师";
				$kemu = pdo_fetch("SELECT sname FROM " . tablename($this->table_classify) . " where sid = :sid And schoolid = :schoolid ", array(':schoolid' => $schoolid,':sid' => $row['km_id']));
				$leave1[$key]['kemu'] = $kemu['sname'];
				$leave1[$key]['time'] = sub_day($row['createtime'])."前";
				mload()->model('read');
				$ydrs = check_readtype($weid,$schoolid,$openid,$row['id'],2);
				if($ydrs == 2){
					$leave1[$key]['ydrs'] = "未读";
				}
			}
			$datas = array(
			'ret' => array('code' => '200','msg' => 'success'),
			'data' => array(
						'dataList' => $leave1,
						'nowPage' => $nowPage,
							)
					);		
			echo json_encode($datas);
			exit;
		}        		
        if(!empty($it)){			
			$this->checkobjiect($schoolid, $student['id'], $obid);				 						
		    include $this->template(''.$school['style2'].'/szuoyelist');
        }else{
			session_destroy();
            include $this->template('bangding');
        }        
?>